<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .box {
      position: relative;
      width: 650px;
      height: 400px;
      margin: 100px auto;
      padding: 0;
    }

    h3 {
      margin: 50px auto;
      font-weight: 400;
      text-align: center;
    }

    .box1 {
      margin: 15px auto;
      border-bottom: 1px solid grey;
      width: 400px;
    }

    .box1 input {
      width: 300px;
      height: 30px;
      border: 0;
      outline: none;
    }

    .box2 {
      position: relative;
      margin: 15px auto;
      width: 400px;
      border-bottom: 1px solid grey;
    }

    .box2 input {
      width: 300px;
      height: 30px;
      border: 0;
      outline: none;
    }

    button {
      position: absolute;
      top: 170px;
      left: 127px;
      margin: 20px auto;
      width: 400px;
      height: 40px;
      background-color: red;
      text-align: center;
      border: 0;
    }

    .box2 img {
      position: absolute;
      top: 2px;
      right: 2px;
      width: 24px;
    }
  </style>
</head>

<body>
  <div class="box">
    <h3>京东登录</h3>
    <div class="box1">
      <input type="text" value="请输入账号">
    </div>
    <div class="box2">
      <label for="">
        <img src="img/close.png" alt="" id="eye">
      </label>
      <input type="password" value="" id="psw">
    </div>
    <button>登录</button>
  </div>
  <script>
    var eye = document.getElementById('eye');
    var psw = document.getElementById('psw');
    var flag = 0;
    eye.onclick = function () {
      if (flag == 0) {
        psw.type = 'text';
        eye.src = 'img/open.png';
        flag = 1;
      } else {
        psw.type = 'password';
        eye.src = 'img/close.png';
        flag = 0;
      }
    }
  </script>
</body>

</html>